﻿///
/// Test script file NetworkDeployTest.fsx.
/// Test for NetworkDeploy.fs
///

#load "Network.fs"
#load "NetworkDeploy.fs"
#load "NetworkSetup.fs"

open PathFinder.Network
open PathFinder.NetworkSetup
open PathFinder.NetworkDeploy

(* Test with adjacency *)
printfn "-------------------------------------------------------"
printfn "Beginning Network Deploy test using adjacency matrix..."
printfn "-------------------------------------------------------"
printfn "Creating node ids"
let nodeA = "NodeA"
let nodeB = "NodeB"
let nodeC = "NodeC"
let nodeD = "NodeD"
printfn "We have: %s %s %s %s %s %s" nodeA nodeB nodeC nodeD
printfn "Adding adjacencies..."
let mutable nam = NetworkAdjacencyMatrix ()
AddAdjacency (nam, (nodeA, nodeB), 2.3)
AddAdjacency (nam, (nodeA, nodeC), 3.2)
AddAdjacency (nam, (nodeA, nodeD), 2.1)
AddAdjacency (nam, (nodeB, nodeA), 4.6)
AddAdjacency (nam, (nodeC, nodeA), 2.7)
AddAdjacency (nam, (nodeD, nodeA), 1.2)
AddAdjacency (nam, (nodeD, nodeC), 8.1)
nam <- (nam |> NormalizeAdjacencyMatrix)
printfn "%s" (nam |> PrintAdjacencyMatrix)
printfn "Deploying..."
let nd = NetworkDeployment ()
nd.Deploy (nam)
printfn "Node ==> %s" (nd.["NodeA"].Value.ToString ())
for i in nd.["NodeA"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd.["NodeB"].Value.ToString ())
for i in nd.["NodeB"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd.["NodeC"].Value.ToString ())
for i in nd.["NodeC"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd.["NodeD"].Value.ToString ())
for i in nd.["NodeD"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))

(* Test without adjacency *)
printfn "------------------------------------------------"
printfn "Beginning Network Deploy test using simpleton..."
printfn "------------------------------------------------"
let setupnodeA = {Node = "NodeA"; Coordinates = (10.0, 12.0)}
let setupnodeB = {Node = "NodeB"; Coordinates = (8.0, 12.0)}
let setupnodeC = {Node = "NodeC"; Coordinates = (20.0, 12.0)}
let setupnodeD = {Node = "NodeD"; Coordinates = (30.0, 12.0)}
let sutupnodes = [setupnodeA; setupnodeB; setupnodeC; setupnodeD]
let setupconn1 = {NodeFrom = "NodeA"; NodeTo = "NodeB"; Cost = 10.0}
let setupconn2 = {NodeFrom = "NodeB"; NodeTo = "NodeC"; Cost = 10.0}
let setupconn3 = {NodeFrom = "NodeC"; NodeTo = "NodeD"; Cost = 10.0}
let setupconns = [setupconn1; setupconn2; setupconn3]
let nd2 = NetworkDeployment ()
nd2.Deploy (sutupnodes, setupconns)
printfn "Node ==> %s" (nd2.["NodeA"].Value.ToString ())
for i in nd2.["NodeA"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd2.["NodeB"].Value.ToString ())
for i in nd2.["NodeB"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd2.["NodeC"].Value.ToString ())
for i in nd2.["NodeC"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))
printfn "Node ==> %s" (nd2.["NodeD"].Value.ToString ())
for i in nd2.["NodeD"].Value.Neighbourhood do
    printfn "Neigh ==> %s" (PrintNeighbour (i))